// 去除html标签
export const htmlSafeStr = (str) => {
    return str.replace(/<[^>]+>/g, "")
}


//1、字符串转换为数组
// var string = '123,456,789';
// var stringResult = sting.split(',');
// console.log(stringResult) //输出[123,456,789]
//
// var string2 = 'abcdef'
// var string2Result = string2.split('')
// console.log(string2Result) //输出['a','b','c','d','e','f']


//2、数组转换为字符串
// var array = ['abc', 'def', 'hig']
// var arrayResult = array.join(',')
// console.log(arrayResult) // 输出"abc,def,hig"


/**
 * 指定字符串 溢出显示省略号
 * @param {String} str
 * @param {Number} num
 */
export const getSubStringSum = (str = "", num = 1) => {
    let newStr;
    if (str) {
        str = str + '';
        if (str.trim().length > num) {
            newStr = str.trim().substring(0, num) + "...";
        } else {
            newStr = str.trim();
        }
    } else {
        newStr = ''
    }
    return newStr;
}